package converter;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import repository.ItemRepository;
import domain.Item;

@Component
public class ItemConverter implements Converter<String, Item>{
	
	private ItemRepository itemRepository;
	
	@Autowired
	public ItemConverter(ItemRepository itemRepository) {
		this.itemRepository = itemRepository;
	}

	@Override
	public Item convert(String source) {
		return itemRepository.getItem(Integer.valueOf(source));
	}

}
